{include file="header.html"}    
<script type="text/javascript" src="{lib file=cart.js}" charset="utf-8"></script>
{include file="title.html"}
<style>
    .checkall,.checkitem{width:20px;height: 20px;margin-right: 10px;}
</style>
<div class=" content">
<!--{foreach from=$carts item=cart key=store_id}-->
<section class="cart-list store-each" data-storeid="{$store_id}">
    <div class="mt">
        <input type="checkbox" checked='checked' class="checkall"/>{$lang.store}: {$cart.store_name|escape}
    </div>
    <div class="mc">
        <!--{foreach from=$cart.goods item=goods}-->
        <dl id="cart_item_{$goods.rec_id}" class="goods-each">
            <dd style='width:40px'><input type="checkbox" checked='checked' value="{$goods.rec_id}" class="checkitem" data-subtotal="{$goods.subtotal}"/></dd>
            <dt>
                <a href="{url app=goods&id=$goods.goods_id}"> <img src="{$site_url}/{$goods.goods_image}" /></a>
            </dt>
            <dd>
                <p class="name">{$goods.goods_name|escape}<!--{if $goods.specification}-->({$goods.specification})<!--{/if}--></p>
                <p class="price">{$lang.price}：<strong>{$goods.price|price}</strong></p>
                <p class="c_oprate">
                    <span class="white_btn" onclick="decrease_quantity({$goods.rec_id});">-</span>
                    <input type="text" id="input_item_{$goods.rec_id}"  value="{$goods.quantity}" orig="{$goods.quantity}"  class="addtext"  id="input_item"  onkeyup="change_quantity({$store_id}, {$goods.rec_id}, {$goods.spec_id}, this);"  changed="{$goods.quantity}"/>
                    <span class="white_btn" onclick="add_quantity({$goods.rec_id});">+</span>
                    <a href="javascript:void(0)" onclick="drop_cart_item({$store_id}, {$goods.rec_id});"> <span class="close"><img src="{res file=images/del.png}" style="border:none; width:20px;height:20px;margin:0 0 5px 0;" /></span></a>
                </p>
            </dd>
        </dl>
        <!--{/foreach}-->
        <div class="count">
            <a style="text-align: right">{$lang.Aggregate}: <strong id='cart{$store_id}_amount'>{$cart.amount|price}</strong></a>
       </div>
    </div>
</section>
<!--{/foreach}-->
<div class="cart-list">
<div class="mc">
<div class="count">
<a href="javascript:go_to_order()" class="jie">{$lang.To_settle_accounts}</a>
</div>
</div>
</div>
</div>
<script>
    $(function(){
        $("img").each(function(){
            var temp_spec=$(this).attr('src');
            if(temp_spec.indexOf('/goodsspec/')>-1){
                var my_site=SITE_URL;
                $(this).attr('src',my_site.replace('/mobile','/')+temp_spec);
                $(this).css('width','24px');
                $(this).css('height','24px');
            }
        })
    })
</script>
<script>
    $(function(){
            /* 全选 */
    $('.checkall').click(function(){
        var _self = this;
        $(this).parents('.cart-list').find('.checkitem').each(function(){
            if (!this.disabled)
            {
                $(this).attr('checked', _self.checked);
            }
        });
        $(this).attr('checked', this.checked);
    });
    $(".content input[type=checkbox]").change(function(){
        $(".store-each").each(function(){
            var subtotal=0;
            $(this).find('.checkitem:checked').each(function(){
                var price=parseFloat($(this).attr('data-subtotal'));
                subtotal=ForDight(subtotal+price,2);
            });
            var store_id=$(this).attr('data-storeid');
            $(this).find('#cart'+store_id+'_amount').text(price_format(subtotal));
        });
        
    });
    })
    function go_to_order(){
                    if ($('.checkitem:checked').length == 0) {
                return false;
            }

            var items = '';
            $('.checkitem:checked').each(function() {
                items += this.value + ',';
            });
            items = items.substr(0, (items.length - 1));

            var uri =  'index.php?app=order&goods=cart&batch=1&rec_ids=' + items;
            window.location.href=uri;return;
    }
    //四舍五入函数
function   ForDight(Dight,How)  
{  
            Dight   =   Math.round   (Dight*Math.pow(10,How))/Math.pow(10,How);  
            return   Dight;  
}  
</script>


{include file="footer.html"}

